<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P58 【例3-4】demo04.html</title>
</head>

<body>
    <script>
        var arr = [10, 2, 5, 27, 98, 31];
        console.log('待排序的数组：' + arr);
        for (var i = 1; i < arr.length; ++i) {
            for (var j = 1; i < arr.length - i; ++j) {
                if (arr[j] > arr[j + 1]) {
                    [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
                }
            }
        }
        console.log('排序后的数组：' + arr);
    </script>
    <a href="../首页/page03.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>